import { _decorator } from "cc";
import { app } from "db://app-game/core/app";
import { ecs } from "db://app-game/libs/ecs/ECS";
import { CCComp } from "db://app-game/module/common/CCComp";
import { UIID } from "../../../../common/config/GameUIConfig";
import { smc } from "../../../singleton/SingletonModuleComp";
import { Level } from "../../level/Level";

const { ccclass, property } = _decorator;

/** 关卡视图组件 */
@ccclass("HomeViewComp")
@ecs.register("HomeView", false)
export class HomeViewComp extends CCComp {
  /** 打开桌面弹窗 */
  openPopupsDesktop() {
    // 1. 删除
    app.gui.remove(UIID.Home);

    // 2.设置单例加载关卡页面
    smc.level = ecs.getEntity<Level>(Level);

    // 3.加载关卡数据，并跳转关卡页面
    smc.level.LevelModel.id = 0;
    smc.level.goto();
  }

  reset(ent: ecs.Entity): void {}
}
